<script setup lang="ts">
const { waterForm, tableHeaders } = defineProps<{
  waterForm: Object; // 定义采样时间的类型
  tableHeaders: Array; // 定义采样时间的类型
  tabler: Array; // 定义采样时间的类型
}>();
</script>

<template>
  <div>
    <div
      v-for="(pageData, pageIndex) in tableHeaders"
      :key="pageIndex"
      style="padding: 0 30px"
    >
      <h1 style="text-align: center; padding-top: 40px">
        土壤/沉积物 pH分析原始记录
      </h1>
      <div>SXLPHJ/JL/CX-22-82</div>
      <table class="table">
        <tr style="background-color: #f2f2f2">
          <td>任务编号</td>
          <td>
            <span>{{ waterForm.task_name }}</span>
          </td>
          <td>采样日期</td>
          <td>
            <span>{{ waterForm.sampling_time }}</span>
          </td>
          <td>分析日期</td>
          <td>
            <span>{{ waterForm.anal_time }}</span>
          </td>
        </tr>
        <!-- 第一行 -->
        <tr>
          <td>分析方法</td>
          <td colspan="3">
            <span>{{ waterForm.method }}</span>
          </td>
          <td>样品类别</td>
          <td>
            <span>{{ waterForm.category_id }}&nbsp;℃</span>
          </td>
        </tr>
        <tr style="background-color: #f2f2f2">
          <td>分析仪器</td>
          <td>
            <div
              v-for="(item, index) in waterForm.device.device_name"
              :key="index"
            >
              {{ item }}
            </div>
          </td>
          <td>仪器型号</td>
          <td>
            <div
              v-for="(item, index) in waterForm.device.device_model"
              :key="index"
            >
              {{ item }}
            </div>
          </td>
          <td>仪器编号</td>
          <td style="width: 100px">
            <div
              v-for="(item, index) in waterForm.device.device_number"
              :key="index"
            >
              {{ item }}
            </div>
          </td>
        </tr>
        <tr>
          <td>温度补偿</td>
          <td>
            <span>{{ waterForm.temperature_bc }}℃</span>
          </td>
          <td>环境温度</td>
          <td>
            <span>{{ waterForm.temperature }}℃</span>
          </td>
          <td>环境湿度</td>
          <td>
            <span>{{ waterForm.humidity }}%RH</span>
          </td>
        </tr>
        <tr>
          <td>标准缓冲溶液理论值</td>
          <td>
            <span>{{ waterForm.bzhcry.bz_hcyllz1 }}</span>
          </td>
          <td colspan="3">
            <span>{{ waterForm.bzhcry.bz_hcyllz2 }}</span>
          </td>
          <td>
            <span>{{ waterForm.bzhcry.bz_hcyllz3 }}</span>
          </td>
        </tr>
        <tr>
          <td>测定值</td>
          <td>
            <span>{{ waterForm.cdz.cdz1 }}</span>
          </td>
          <td colspan="3">
            <span>{{ waterForm.cdz.cdz2 }}</span>
          </td>
          <td>
            <span>{{ waterForm.cdz.cdz3 }}</span>
          </td>
        </tr>
      </table>
      <table class="table">
        <tr>
          <td>样品编号</td>
          <td>取样量(g)</td>
          <td>浸提剂体积V(mL)</td>
          <td>pH值</td>
          <td>备注</td>
        </tr>

        <tr v-for="(row, rowIndex) in pageData" :key="rowIndex">
          <td v-for="(key, colIndex) in Object.keys(row)" :key="colIndex">
            {{ row[key] }}
          </td>
        </tr>
      </table>
      <table class="table">
        <tr>
          <td colspan="6">
            <div class="table-td">平行样测定</div>
          </td>
        </tr>
        <tr>
          <td>样品编号</td>
          <td>PH值</td>
          <td>平均值</td>
          <td>差值(PH单位)</td>
          <td>允许差(PH单位)</td>
          <td>是否合格</td>
        </tr>
        <tr>
          <td>
            {{ waterForm.pxycd.sampleNumber }}
          </td>
          <td>
            {{ waterForm.pxycd.PHValueOne }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.average }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.difference }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.allowed }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.qualified }}
          </td>
        </tr>
        <tr>
          <td>
            {{ waterForm.pxycd.sampleNumberTow }}
          </td>
          <td>{{ waterForm.pxycd.PHValueTow }}</td>
        </tr>
        <!-- 1111 -->
        <tr>
          <td>
            {{ waterForm.pxycd.sampleNumberThree }}
          </td>
          <td>
            {{ waterForm.pxycd.PHValueThree }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.averageThree }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.differenceThree }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.allowedThree }}
          </td>
          <td rowspan="2">
            {{ waterForm.pxycd.qualifiedThree }}
          </td>
        </tr>
        <tr>
          <td>
            {{ waterForm.pxycd.sampleNumberFour }}
          </td>
          <td>{{ waterForm.pxycd.PHValueFour }}</td>
        </tr>
        <!-- 3233 -->
        <tr>
          <td colspan="6">
            <div class="table-td">标准样品测定</div>
          </td>
        </tr>
        <tr>
          <td colspan="2">标样批号</td>
          <td colspan="2">测定结果</td>
          <td>标准值</td>
          <td>是否合格</td>
        </tr>
        <tr>
          <td colspan="2">
            {{ waterForm.bzycd.byph }}
          </td>
          <td colspan="2">
            {{ waterForm.bzycd.cdjg }}
          </td>
          <td>
            {{ waterForm.bzycd.bzz }}
          </td>
          <td>
            {{ waterForm.bzycd.qualified }}
          </td>
        </tr>
        <tr>
          <td colspan="2">备注</td>
          <td colspan="4">
            {{ waterForm.notes }}
          </td>
        </tr>
      </table>
      <div
        style="
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-top: 20px;
        "
      >
        <div>分析人：</div>
        <div>校核人：</div>
        <div>审核人：</div>
        <div>第 {{ pageIndex + 1 }} 页 / 共 {{ tableHeaders.length }} 页</div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 设置表格的边框、外边距等 */
table {
  border-collapse: collapse;
  width: 100%;
}

table th,
table td {
  border: 1px solid #ddd;
  padding: 2px 10px;
  font-size: 11px;
  text-align: center;
  height: 20px;
}

tr {
  page-break-inside: avoid;
}

.fs12 {
  font-size: 12px;
}

.table {
  width: 100%;
}

/* 打印时隐藏所有默认的头部和尾部 */
@media print {
  /* 隐藏页眉和页脚 */
  @page {
    margin: 0;
  }

  table {
    page-break-inside: avoid;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  th,
  td {
    page-break-inside: avoid;
  }

  body {
    margin: 0;
    padding: 0;
    zoom: 100%;
  }

  div {
    page-break-inside: avoid;
  }

  /* 禁用打印页脚和页眉 */
  .no-print {
    display: none;
  }

  /* 如果你不想打印特定元素，可以这样设置 */
  header,
  footer,
  nav,
  .no-print {
    display: none !important;
  }

  /* 保证内容区域不受其他元素影响 */
  .content {
    display: block;
  }
}
</style>
